package br.com.salaodebeleza.domain;

// Generated 26/11/2012 17:38:47 by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TbMenu generated by hbm2java
 */
@Entity
@Table(name = "tb_menu", schema = "public")
public class TbMenu implements java.io.Serializable {

	private long id;
	private TbMenu tbMenu;
	private String nome;
	private String link;
	private String ativo;
	private Set<TbMenu> tbMenus = new HashSet<TbMenu>(0);
	private Set<TbGrupo> tbGrupos = new HashSet<TbGrupo>(0);
	private TbIcone tbIcone;
	
	public TbMenu() {
	}

	public TbMenu(long id, String nome, String ativo, String icone) {
		this.id = id;
		this.nome = nome;
		this.ativo = ativo;
	}

	public TbMenu(long id, TbMenu tbMenu, String nome, String link,
			String ativo, String icone, Set<TbMenu> tbMenus,
			Set<TbGrupo> tbGrupos) {
		this.id = id;
		this.tbMenu = tbMenu;
		this.nome = nome;
		this.link = link;
		this.ativo = ativo;
		this.tbMenus = tbMenus;
		this.tbGrupos = tbGrupos;
	}

	@Id
	@GeneratedValue
	@Column(name = "ID", unique = true, nullable = false, precision = 22, scale = 0)
	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MENU_MASTER")
	public TbMenu getTbMenu() {
		return this.tbMenu;
	}

	public void setTbMenu(TbMenu tbMenu) {
		this.tbMenu = tbMenu;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ICON")
	public TbIcone getTbIcone() {
		return this.tbIcone;
	}

	public void setTbIcone(TbIcone tbIcone) {
		this.tbIcone = tbIcone;
	}

	@Column(name = "NOME", nullable = false, length = 50)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@Column(name = "LINK", length = 50)
	public String getLink() {
		return this.link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	@Column(name = "ATIVO", nullable = false, length = 1)
	public String getAtivo() {
		return this.ativo;
	}

	public void setAtivo(String ativo) {
		this.ativo = ativo;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "tbMenu")
	public Set<TbMenu> getTbMenus() {
		return this.tbMenus;
	}

	public void setTbMenus(Set<TbMenu> tbMenus) {
		this.tbMenus = tbMenus;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "tb_grupo_menu", schema = "public", joinColumns = { @JoinColumn(name = "MENU", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "GRUPO", nullable = false, updatable = false) })
	public Set<TbGrupo> getTbGrupos() {
		return this.tbGrupos;
	}

	public void setTbGrupos(Set<TbGrupo> tbGrupos) {
		this.tbGrupos = tbGrupos;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (!(obj instanceof TbMenu)) return false;
		
		return this.id == ((TbMenu)obj).getId();
	}

}
